package com.liu.controller;

import com.liu.bean.Oper;
import com.liu.service.OperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

@Controller
public class UserController {
    @Autowired
    OperService operService;
    @RequestMapping("/login")
    @ResponseBody
    public Map<String,Object> login2(@RequestParam("phone") String phone, @RequestParam("password") String password){
        System.out.println(phone+"<->"+password);
        Oper oper=operService.selectByphone(phone);
        Map<String,Object> map=new HashMap<>();
        map.put("res","error");
        map.put("data","");
        if (oper!=null){
            if (oper.getPwd().equals(password)){
              map.put("res","success");
              map.put("data",oper);
            }
        }

        return map;
    }
}
